<?php

/**
 *  This file is part of Urd.
 *
 *  Urd is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *  Urd is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program. See the file "COPYING". If it does not
 *  exist, see <http://www.gnu.org/licenses/>.
 *
 * $LastChangedDate: 2008-07-19 14:26:35 +0200 (Sat, 19 Jul 2008) $
 * $Rev: 1309 $
 * $Author: gavinspearhead $
 * $Id: defines.php 1309 2008-07-19 12:26:35Z gavinspearhead $
 */

// username for the superuser
define ('SUPER_USER', 'root');
define ('SUPER_USERID', 0);

define ('URDD_DOWNLOAD_LOCKFILE', '.urdd_lock');
define ('URDD_PORT', 11666);

// time out for checking the queue
define('DEFAULT_CHECK_TIMEOUT', 5000000);
// timeout in seconds that a socket will timeout
define('DEFAULT_SOCKET_TIMEOUT', 30);

// the time the server the thread number will remain decreased
define ('CONNECT_CHECK_TIME', 60);
// the time a thread will remain paused after a connection error
define ('CONNECT_PAUSE_TIME', 60);

// Error codes
define('NO_ERROR', 0);
define('GROUP_NOT_FOUND', 1);
define('DB_FAILURE', 2);
define('UNKNOWN_ACTION', 3);
define('FEED_NOT_FOUND', 4);
define('INTERNAL_FAILURE', 5);
define('CONFIG_ERROR', 6);
define('SOCKET_FAILURE', 7);
define('COMMANDLINE_ERROR',8);
define('QUEUE_ERROR', 9);
define('NNTP_NOT_CONNECTED_ERROR', 10);
define('COULD_NOT_CHECK_VERSION', 11);
define('URDLAND_CONNECT_ERROR', 12);
define('FILE_NOT_FOUND', 13);
define('DB_LOCKED', 14);
define('NOT_ALLOWED', 15);
define('UNKNOWN_ERROR', 16);
define('RESTART_URDD', 17);
define('POST_FAILURE', 18);
define('FILE_NOT_CREATED', 19);
define('ENCRYPTED_RAR', 20);


//maximum buffer size for socket_read
define('MAX_BUFF_SIZE', 1024);

// debug values
define('DEBUG_ALL', 255); /// all debug messages
define('DEBUG_MAIN', 1);  /// everything in the main loop or before it
define('DEBUG_WORKER', 2); /// all messages that are in forked processes
define('DEBUG_SERVER', 4); /// all messages that are in the main process... stuff called from the main loop
define('DEBUG_SIGNAL', 8); /// all messages that are in the signal handlers
define('DEBUG_DATABASE', 16); /// all messages that are in the database classes
define('DEBUG_NNTP', 32); /// all messages that are in the nntp classes
define('DEBUG_CLIENT', 64); /// all messages that are in the (web) client
define('DEBUG_HTTP', 128);

// thread error codes
// values determine order in transfer page:
define('DOWNLOAD_READY', 0);    // ready to put on queue
define('DOWNLOAD_ACTIVE', 1);   // downloading
define('DOWNLOAD_QUEUED', 2);   // put on queue
define('DOWNLOAD_PAUSED', 3);   // download paused
define('DOWNLOAD_FINISHED', 4); // download succeeded and rar/par successful
define('DOWNLOAD_CANCELLED', 5);// download cancelled
define('DOWNLOAD_STOPPED', 6);   // download is terminated, but requeued
define('DOWNLOAD_SHUTDOWN', 7); // used when process is sent kill term command
define('DOWNLOAD_COMPLETE', 8); // download succeeded but need to run par/unrar now
define('DOWNLOAD_RAR_FAILED', 9); // download but rar failed
define('DOWNLOAD_CKSFV_FAILED', 10); // download but rar failed
define('DOWNLOAD_PAR_FAILED', 11); // download but par2 failed
define('DOWNLOAD_FAILED', 12); // Article could not be dled or complete dl failed (esp preview). 
define('DOWNLOAD_ERROR', 255);  // an error occurred

define('POST_READY', 0);    // ready to put on queue
define('POST_RARRED', 1);    // rar complete
define('POST_PARRED', 2);    // par2 complete
define('POST_YYENCODED', 3);    // yyencode complete
define('POST_ACTIVE', 11);   // posting
define('POST_QUEUED', 12);   // put on queue
define('POST_PAUSED', 13);   // posting paused
define('POST_FINISHED', 14); // posting succeeded 

define('POST_CANCELLED', 25);// post cancelled
define('POST_STOPPED', 26);   // post is terminated, but requeued
define('POST_SHUTDOWN', 27); // used when process is sent kill term command
//define('POST_COMPLETE', 28); //  succeeded but need to run par/unrar now
define('POST_RAR_FAILED', 29); // POST could not succeed, rar failed
define('POST_PAR_FAILED', 30); // POST could not succeed,  par2 failed
define('POST_YYENCODE_FAILED', 31); // POST could not succeed, yyencode faild
define('POST_FAILED', 31); // posting to the server failed

define('POST_ERROR', 255);  // an error occurred

// Queue info status
define('QUEUE_QUEUED', 'Queued');
define('QUEUE_FINISHED', 'Finished');
define('QUEUE_FAILED', 'Failed');
define('QUEUE_RUNNING', 'Running');
define('QUEUE_PAUSED', 'Paused');
define('QUEUE_CANCELLED', 'Cancelled');
define('QUEUE_CRASH', 'Crashed');
define('QUEUE_REMOVED', 'Removed');

define('DLTYPE_NORMAL', 1);
define('DLTYPE_PREVIEW', 2);
define('DLTYPE_NZB', 3);

define('DO_UNPAR', 1);
define('DO_UNRAR', 2);
define('DO_DELETE_FILES', 4);
define('DO_FIRST_RUN', 8);

define ('RAR_EXT', 'rar');
define ('ACE_EXT', 'ace');
define ('ZIP_EXT', 'zip');
define ('ARJ_EXT', 'arj');
define ('ZR7_EXT', '7z'); // 7zr.. but can't start with a 7
define ('PAR_EXT', 'par2');
define ('SFV_EXT', 'svf');
define ('CAT_EXT', 'cat');
define ('UUE_EXT', 'urd_uuencoded_part');

$archives = array (RAR_EXT, ACE_EXT, ZIP_EXT, ARJ_EXT, ZR7_EXT);

define ('NNTP_ABS_MAX', 32); // the maximum number of connection that urdd will open at the same time

define ('DEFAULT_PER_PAGE', 100);

define ('MAX_SEARCH_BUTTONS', 10); // the maximum number of search buttons placed on the browse page
define ('MAX_REQUEUE_COUNT',10000); // the maximum number of times an item can be requeued
define ('MIN_PASSWORD_LENGTH', 8);
define ('MAX_DL_NAME', 42);
define ('SKIPPER_SIZE', 19);
define ('MAX_NAME_SIZE', 40);
define ('DL_BATCH_SIZE', 10);
define ('POST_BATCH_SIZE', 5);
define ('PV_BATCH_SIZE', 5);
define ('MAX_PREVIEW_SIZE', 2 * 1024 * 1024); // 2 MB


define ('MAX_ART_LINE_COUNT', 50);
define ('MAX_SQL_INSERTS', 50);
define ('TEXT_BOX_SIZE', 40);
define ('NUMBER_BOX_SIZE', 5);

//define ('DEFAULT_NNTP_VERSION', '1.0.1'); // The latest stable version and default on Ubuntu installs

define ('DEFAULT_LOG_LINES', 1000);
define ('MAX_LOG_LINES', 10000);

define ('CLEAN_DIR_SLACKTIME', 3 * 24 * 60 * 60);

// users status
define ('USER_INACTIVE', 0);
define ('USER_ACTIVE', 1);
define ('USER_PENDING', 2);

define ('USER_USER', 0);
define ('USER_ADMIN', 1);

define ('NG_SUBSCRIBED', 1);
define ('NG_UNSUBSCRIBED', 0);

define ('RSS_SUBSCRIBED', 1);
define ('RSS_UNSUBSCRIBED', 0);


define ('VERSION_CHECK_URL', 'http://www.urdland.com/checkversion.php');
define ('DOWNLOAD_URL', 'http://www.urdland.com/');

define ('UPDATE_NO_UPDATE', 0);
define ('UPDATE_NEW_VERSION', 1);
define ('UPDATE_SECURITY_FIX', 2);
define ('UPDATE_BUG_FIX', 4);
define ('UPDATE_NEW_FEATURE', 8);
define ('UPDATE_OTHER', 128);

define ('DEFAULT_PRIORITY', 50);

define ('URD_NOERROR', 0);
define ('URD_FILENOTFOUND', 1);
define ('URD_UNKNOWNERROR', 2);

define ('DEFAULT_TEMPLATE', 'default');
define ('DEFAULT_LANGUAGE', 'english.php');

define ('CHALLENGE_LENGTH', 16);
//define ('CHALLENGE_TIMEOUT', 1800);
define ('CHALLENGE_TIMEOUT', 86400);

//define ('MAX_INSERT_PARTS', 50);
define ('MAX_INSERT_PARTS', 5000);
define ('GROUPS_FILE', '/etc/group');

define ('PREVIEW_PATH',     'preview/');
define ('TMP_PATH',         'tmp/');
define ('DONE_PATH',        'done/');
define ('NZB_PATH',         'nzb/');
define ('SPOOL_PATH',       'spool/');
define ('POST_PATH',        'post/');
define ('SCRIPTS_PATH',     'scripts/');


define ('URDLAND_PATH_S', 'https://urdland.com/xmlrpc.php');
define ('URDLAND_PATH', 'http://urdland.com/xmlrpc.php');

$yes = array ('1', 'TRUE', 'ON', 'YES');
$no  = array ('0', 'FALSE', 'OFF', 'NO');

$log_str = array (
	LOG_DEBUG=>'DEBUG',
	LOG_INFO=>'INFO',
	LOG_NOTICE=>'NOTICE',
	LOG_WARNING=>'WARNING',
	LOG_ERR=>'ERROR',
	LOG_CRIT=>'CRITICAL',
	LOG_ALERT=>'ALERT',
	LOG_EMERG=>'EMERGENCY'
);

// Queuing positions
define ('QUEUE_TOP', 1);
define ('QUEUE_BOTTOM', 2);

// encoding types
define ('TYPE_UUENCODED', 1);
define ('TYPE_YYENCODED', 2);
define ('TYPE_XXENCODED', 3);
define ('TYPE_MIMEENCODED', 4);
define ('TYPE_UNKNOWN', 255);

define ('DIRTY', 1);
define ('CLEAN', 0);

define ('RIGHTS_STR','cCrRuUdDPpAa');
// C: seteditor
// R: unused
// U: unused
// D: unused
// P: posting/ uploading
// A: autodownload


define ('DEFAULT_USENET_SERVER_PRIORITY', 10);
define ('DISABLED_USENET_SERVER_PRIORITY', 0);

define ('URDD_NOERROR', 0);
define ('URDD_SHUTDOWN', 3);
define ('URDD_RESTART', 5);
define ('URDD_CLOSE_CONN', 1);
define ('URDD_NOCOMMAND', 2);
define ('URDD_ERROR', 4);


define ('SETTYPE_UNKNOWN', 0);
define ('SETTYPE_MOVIE', 1);
define ('SETTYPE_ALBUM', 2);
define ('SETTYPE_IMAGE', 3);
define ('SETTYPE_SOFTWARE', 4);
define ('SETTYPE_TVSERIES', 5);
define ('SETTYPE_EBOOK', '6');
define ('SETTYPE_DOCUMENTARY', '7');
define ('SETTYPE_GAME', '8');
define ('SETTYPE_TVSHOW', '9');
define ('SETTYPE_OTHER', 100);

$SETTYPES = array (SETTYPE_UNKNOWN, SETTYPE_MOVIE, SETTYPE_ALBUM,SETTYPE_IMAGE,SETTYPE_SOFTWARE, SETTYPE_TVSERIES, SETTYPE_EBOOK, SETTYPE_GAME, SETTYPE_DOCUMENTARY, SETTYPE_TVSHOW, SETTYPE_OTHER);


define ('STAT_ACTION_UNUSED', 0);
define ('STAT_ACTION_DOWNLOAD', 1);
define ('STAT_ACTION_PREVIEW', 2);
define ('STAT_ACTION_UPDATE', 3);
define ('STAT_ACTION_EXPIRE', 4);
define ('STAT_ACTION_PURGE', 5);
define ('STAT_ACTION_WEBVIEW', 6);
define ('STAT_ACTION_IMPORTNZB', 7);
define ('STAT_ACTION_GETNZB', 8);
define ('STAT_ACTION_POST', 9);

define('CONFIG_LEVEL_ALWAYS', 0);
define('CONFIG_LEVEL_BASIC', 10);
define('CONFIG_LEVEL_ADVANCED', 50);
define('CONFIG_LEVEL_MASTER', 100);

define ('MARKING_NEW_OFF', 0); // not yet marked yet, but may still be auto_marked
define ('MARKING_ON', 1);      // marked
define ('MARKING_OFF', 255);   // not marked and will not be automarked

define ('USERSETTYPE_GROUP', 0);
define ('USERSETTYPE_RSS', 1);

define ('BINARYID_CACHE_SIZE', 32); // number of binary IDs we keep  in memory to minimise the redundant subjects and posters we store

define('MAGPIE_FETCH_TIME_OUT', 60);
define('MAGPIE_FETCHCONNECT_TIME_OUT', 30);
define('MAGPIE_OUTPUT_ENCODING', 'ISO-8859-1');
define('MAGPIE_CACHE_AGE', 60 * 60); // one hour

define('MAGPIE_USER_AGENT', 'URD-MAGPIE/0.73 (Cached)');

define('ESI_NOT_COMMITTED', 0);
define('ESI_COMMITTED', 1);

define('URDD_SCRIPT_EXT', 'urdd_sh');

//define('GENSETS_STEPSIZE', 4000);
define('GENSETS_STEPSIZE', 50);

define ('MIN_OLDER_COUNTER', 5000); 
define ('MAX_OLDER_COUNTER', 10000); 

define ('MAX_EXPIRE_TIME', 365); 

define ('DB_LOCK_TIMEOUT_PREVIEW', 2); 
define ('DB_LOCK_TIMEOUT_DEFAULT', 15); 
define ('MAX_RECONNECTION_ATTEMPTS_PER_THREAD', 15);

define ('RARSCAN_QUEUESIZE', 5);  // Number of article entries in the chunk meta data queue, gives yydecode time to write data before we read it. Per DL thread.
?>
